#include "comm.hpp"
#include <iostream>
#include <string>
#include <cstdlib>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>


int main()
{
    // 打开管道
    int fd = open(FIFO_FILE, O_WRONLY);
    if (fd < 0)
    {
        perror("open");
        exit(FIFO_OPEN_ERR);
    }
    
    std::cout << "client open file done" << std::endl;

    std::string line;
    while (true)
    {
        std::cout << "Please Enter@ ";
        getline(std::cin, line);  

        write(fd, line.c_str(), line.size());
        std::cout << "wirte to server [" << line << "] done" << std::endl;
    }

    close(fd);
    return 0;
}